package com.coffee.admin.controller.supplier;

import com.alibaba.fastjson.JSONObject;
import com.coffee.admin.api.common.service.RedisService;
import com.coffee.admin.api.platform.result.PlatformBaseDeployResult;
import com.coffee.admin.api.platform.service.PlatformBaseDeployService;
import com.coffee.admin.controller.BaseController;
import com.coffee.admin.utils.WeixinGzhAppletsUtil;
import com.coffee.core.anotation.OperLog;
import com.coffee.core.anotation.SupplierLoginCheck;
import com.coffee.core.entity.LoginUser;
import com.coffee.core.entity.Page;
import com.coffee.core.entity.PagerInfo;
import com.coffee.core.enums.ContractTypeEnum;
import com.coffee.core.enums.RoleTypeEnum;
import com.coffee.core.exception.BusinessException;
import com.coffee.core.result.Result;
import com.coffee.core.util.DateUtil;
import com.coffee.order.api.inquire.req.*;
import com.coffee.order.api.inquire.result.*;
import com.coffee.order.api.inquire.service.InquireOrderContractService;
import com.coffee.order.api.inquire.service.InquireOrderService;
import com.coffee.order.api.inquire.service.InquireOrderTestingService;
import org.apache.commons.lang.StringUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@RestController
@RequestMapping("/supplier/inquire")
public class SupplierInquireOrderController extends BaseController {
    private final static Logger logger = LoggerFactory.getLogger(SupplierInquireOrderController.class);

    @DubboReference(check = false)
    private InquireOrderService inquireOrderService;
    @DubboReference(check = false)
    private InquireOrderContractService inquireOrderContractService;
    @DubboReference(check = false)
    private InquireOrderTestingService inquireOrderTestingService;
    @DubboReference(check = false)
    private PlatformBaseDeployService platformBaseDeployService;
    @DubboReference(check = false)
    private RedisService redisService;
    @Value("${parameter.webDomain}")
    private String web;

    private ExecutorService executorService = Executors.newFixedThreadPool(10);

    @OperLog(operModul = "供应商-订单管理-订单列表", operDesc = "查询订单列表")
    @SupplierLoginCheck(alias = "SupplierOrderListAlias")
    @RequestMapping(value = "/order/list", method = {RequestMethod.POST})
    public Result<Page<SupplierSubOrderListResult>> orderList(HttpServletRequest request, @RequestBody SupplierOrderListReq req) {
        LoginUser supplier = getSupplier();
        Result<Page<SupplierSubOrderListResult>> result = Result.success(null);
        PagerInfo pagerInfo = setDefaultPageInfo(req.getPageSize(), req.getPageIndex());
        req.setSupplierId(supplier.getSupplierId());
        Page<SupplierSubOrderListResult> supplierSubOrderListResultPage = inquireOrderService.pageSupplierSubOrderListResult(req, pagerInfo);
        result.setData(supplierSubOrderListResultPage);
        return result;
    }


    @OperLog(operModul = "供应商-订单管理-订单详情", operDesc = "查询订单详情")
    @SupplierLoginCheck(alias = "SupplierOrderListAlias")
    @RequestMapping(value = "/order/detail", method = {RequestMethod.POST})
    public Result<SupplierOrderResult> orderDetail(@RequestBody JSONObject jsonObject, HttpServletRequest request) {
        Integer inquireOrderId = jsonObject.getInteger("inquireOrderId");
        LoginUser supplier = getSupplier();
        Result<SupplierOrderResult> result = Result.success(null);
        SupplierOrderResult supplierOrderResult = null;
        try {
            supplierOrderResult = inquireOrderService.getSupplierOrderResult(inquireOrderId, supplier.getSupplierId(), RoleTypeEnum.SUPPLIER.getCode());
        } catch (BusinessException e) {
            return Result.failed(e.getCode(), e.getMessage());
        }
        result.setData(supplierOrderResult);
        return result;
    }


    @OperLog(operModul = "供应商-订单管理-添加报价", operDesc = "添加报价")
    @SupplierLoginCheck(alias = "SupplierOrderOperationAlias")
    @RequestMapping(value = "/order/add/quotationScheme", method = {RequestMethod.POST})
    public Result<String> orderAddQuotationScheme(HttpServletRequest request, @RequestBody SectionProgrammeReq req) {
        LoginUser supplier = getSupplier();
        Result<String> result = Result.success(null);
        try {
            req.setSupplierId(supplier.getSupplierUserId());
            WeiXinPushResult weiXinPushResult = inquireOrderService.addQuotationScheme(req);
            executorService.execute(new Runnable() {
                @Override
                public void run() {
                    try {
                        Object accessToken = redisService.get("accessToken");
                        String accessTokenStr = null;
                        if (accessToken == null) {
                            JSONObject accessToken1 = WeixinGzhAppletsUtil.getGzhAccessToken();
                            logger.info("accessToken1===" + JSONObject.toJSONString(accessToken1));
                            accessToken1.put("expires_time", DateUtil.addSeconds(new Date(), accessToken1.getInteger("expires_in")));
                            redisService.set("accessToken", accessToken1);
                            accessTokenStr = accessToken1.getString("access_token");
                        } else {
                            JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(accessToken));
                            logger.info("accessToken===" + JSONObject.toJSONString(accessToken));
                            if (jsonObject.getDate("expires_time").before(new Date())) {
                                JSONObject accessToken2 = WeixinGzhAppletsUtil.getGzhAccessToken();
                                logger.info("accessToken2===" + JSONObject.toJSONString(accessToken2));
                                accessToken2.put("expires_time", DateUtil.addSeconds(new Date(), accessToken2.getInteger("expires_in")));
                                redisService.set("accessToken", accessToken2);
                                accessTokenStr = accessToken2.getString("access_token");
                            } else {
                                accessTokenStr = jsonObject.getString("access_token");
                            }
                        }
                        if (StringUtils.isNotEmpty(weiXinPushResult.getOpenId())) {
                            Map<String, String> content = new HashMap<>();
                            content.put("inquireOrderId", weiXinPushResult.getInquireOrderId() + "");
                            content.put("skuName", weiXinPushResult.getSkuName());
                            content.put("status", weiXinPushResult.getStatus());
                            content.put("createTime", DateUtil.getDateTime(weiXinPushResult.getCreateTime()));
                            WeixinGzhAppletsUtil.push("uhgZX_euKA6gvV66W7QroYGubIoJZnE4p3GWiK_2ZgQ"
                                    , accessTokenStr, weiXinPushResult.getOpenId(), content, "`pages/home/index?urlData=` + encodeURIComponent(JSON.stringify(`/pages/mine/subPages/fetures-detail/index?subOrderId=" + weiXinPushResult.getInquireOrderId() + "`))+");
                        }
                    } catch (BusinessException e) {
                        e.printStackTrace();
                        logger.error("#tongliSignContract# error" + e);
                    }
                }
            });
        } catch (BusinessException e) {
            return Result.failed(e.getCode(), e.getMessage());
        }
        result.setData("SUCCESS");
        return result;
    }


    @OperLog(operModul = "供应商-订单管理-卖方确认", operDesc = "卖方确认")
    @SupplierLoginCheck(alias = "SupplierOrderOperationAlias")
    @RequestMapping(value = "/order/sellerConfirm", method = {RequestMethod.POST})
    public Result<String> orderAddQuotationScheme(HttpServletRequest request, @RequestBody SellerConfirmReq req) {
        LoginUser supplier = getSupplier();
        Result<String> result = Result.success(null);
        try {
            req.setUserId(supplier.getSupplierUserId());
            req.setType(RoleTypeEnum.SUPPLIER.getCode());
            WeiXinPushResult weiXinPushResult = inquireOrderService.sellerConfirm(req);
            executorService.execute(new Runnable() {
                @Override
                public void run() {
                    try {
                        Object accessToken = redisService.get("accessToken");
                        String accessTokenStr = null;
                        if (accessToken == null) {
                            JSONObject accessToken1 = WeixinGzhAppletsUtil.getGzhAccessToken();
                            logger.info("accessToken1===" + JSONObject.toJSONString(accessToken1));
                            accessToken1.put("expires_time", DateUtil.addSeconds(new Date(), accessToken1.getInteger("expires_in")));
                            redisService.set("accessToken", accessToken1);
                            accessTokenStr = accessToken1.getString("access_token");
                        } else {
                            JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(accessToken));
                            logger.info("accessToken===" + JSONObject.toJSONString(accessToken));
                            if (jsonObject.getDate("expires_time").before(new Date())) {
                                JSONObject accessToken2 = WeixinGzhAppletsUtil.getGzhAccessToken();
                                logger.info("accessToken2===" + JSONObject.toJSONString(accessToken2));
                                accessToken2.put("expires_time", DateUtil.addSeconds(new Date(), accessToken2.getInteger("expires_in")));
                                redisService.set("accessToken", accessToken2);
                                accessTokenStr = accessToken2.getString("access_token");
                            } else {
                                accessTokenStr = jsonObject.getString("access_token");
                            }
                        }
                        if (StringUtils.isNotEmpty(weiXinPushResult.getOpenId())) {
                            Map<String, String> content = new HashMap<>();
                            content.put("inquireOrderId", weiXinPushResult.getInquireOrderId() + "");
                            content.put("skuName", weiXinPushResult.getSkuName());
                            content.put("status", weiXinPushResult.getStatus());
                            content.put("createTime", DateUtil.getDateTime(weiXinPushResult.getCreateTime()));
                            WeixinGzhAppletsUtil.push("uhgZX_euKA6gvV66W7QroYGubIoJZnE4p3GWiK_2ZgQ"
                                    , accessTokenStr, weiXinPushResult.getOpenId(), content, "`pages/home/index?urlData=` + encodeURIComponent(JSON.stringify(`/pages/mine/subPages/fetures-detail/index?subOrderId=" + weiXinPushResult.getInquireOrderId() + "`))+");
                        }
                    } catch (BusinessException e) {
                        e.printStackTrace();
                        logger.error("#tongliSignContract# error" + e);
                    }
                }
            });
        } catch (BusinessException e) {
            return Result.failed(e.getCode(), e.getMessage());
        }
        result.setData("SUCCESS");
        return result;
    }


    @OperLog(operModul = "供应商-订单管理-订单支付", operDesc = "卖方确认")
    @SupplierLoginCheck(alias = "SupplierOrderOperationAlias")
    @RequestMapping(value = "/order/pay", method = {RequestMethod.POST})
    public Result<String> orderPay(HttpServletRequest request, @RequestBody SellerConfirmReq req) {
        LoginUser supplier = getSupplier();
        Result<String> result = Result.success(null);
        try {
            req.setUserId(supplier.getSupplierUserId());
            req.setType(RoleTypeEnum.SUPPLIER.getCode());
            WeiXinPushResult weiXinPushResult = inquireOrderService.pay(req);
            executorService.execute(new Runnable() {
                @Override
                public void run() {
                    try {
                        Object accessToken = redisService.get("accessToken");
                        String accessTokenStr = null;
                        if (accessToken == null) {
                            JSONObject accessToken1 = WeixinGzhAppletsUtil.getGzhAccessToken();
                            logger.info("accessToken1===" + JSONObject.toJSONString(accessToken1));
                            accessToken1.put("expires_time", DateUtil.addSeconds(new Date(), accessToken1.getInteger("expires_in")));
                            redisService.set("accessToken", accessToken1);
                            accessTokenStr = accessToken1.getString("access_token");
                        } else {
                            JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(accessToken));
                            logger.info("accessToken===" + JSONObject.toJSONString(accessToken));
                            if (jsonObject.getDate("expires_time").before(new Date())) {
                                JSONObject accessToken2 = WeixinGzhAppletsUtil.getGzhAccessToken();
                                logger.info("accessToken2===" + JSONObject.toJSONString(accessToken2));
                                accessToken2.put("expires_time", DateUtil.addSeconds(new Date(), accessToken2.getInteger("expires_in")));
                                redisService.set("accessToken", accessToken2);
                                accessTokenStr = accessToken2.getString("access_token");
                            } else {
                                accessTokenStr = jsonObject.getString("access_token");
                            }
                        }
                        if (StringUtils.isNotEmpty(weiXinPushResult.getOpenId())) {
                            Map<String, String> content = new HashMap<>();
                            content.put("inquireOrderId", weiXinPushResult.getInquireOrderId() + "");
                            content.put("skuName", weiXinPushResult.getSkuName());
                            content.put("status", weiXinPushResult.getStatus());
                            content.put("createTime", DateUtil.getDateTime(weiXinPushResult.getCreateTime()));
                            WeixinGzhAppletsUtil.push("uhgZX_euKA6gvV66W7QroYGubIoJZnE4p3GWiK_2ZgQ"
                                    , accessTokenStr, weiXinPushResult.getOpenId(), content, "`pages/home/index?urlData=` + encodeURIComponent(JSON.stringify(`/pages/mine/subPages/fetures-detail/index?subOrderId=" + weiXinPushResult.getInquireOrderId() + "`))+");
                        }
                    } catch (BusinessException e) {
                        e.printStackTrace();
                        logger.error("#tongliSignContract# error" + e);
                    }
                }
            });
        } catch (BusinessException e) {
            return Result.failed(e.getCode(), e.getMessage());
        }
        result.setData("SUCCESS");
        return result;
    }

    @OperLog(operModul = "供应商-订单管理-上传签约凭证", operDesc = "上传签约凭证")
    @SupplierLoginCheck(alias = "SupplierOrderOperationAlias")
    @RequestMapping(value = "/order/contract", method = {RequestMethod.POST})
    public Result<String> orderContract(HttpServletRequest request, @RequestBody SellerConfirmReq req) {
        LoginUser supplier = getSupplier();
        Result<String> result = Result.success(null);
        try {
            req.setUserId(supplier.getSupplierUserId());
            req.setType(RoleTypeEnum.SUPPLIER.getCode());
            inquireOrderService.contract(req);
        } catch (BusinessException e) {
            return Result.failed(e.getCode(), e.getMessage());
        }
        result.setData("SUCCESS");
        return result;
    }


    @OperLog(operModul = "供应商-订单管理-设置运费", operDesc = "设置运费")
    @SupplierLoginCheck(alias = "SupplierOrderOperationAlias")
    @RequestMapping(value = "/order/setFreight", method = {RequestMethod.POST})
    public Result<String> setFreight(HttpServletRequest request, @RequestBody InquireOrderDeliveryDemandReq req) {
        LoginUser supplier = getSupplier();
        Result<String> result = Result.success(null);
        try {
            req.setUserId(supplier.getSupplierUserId());
            req.setType(RoleTypeEnum.SUPPLIER.getCode());
            WeiXinPushResult weiXinPushResult = inquireOrderService.setFreight(req);
            executorService.execute(new Runnable() {
                @Override
                public void run() {
                    try {
                        Object accessToken = redisService.get("accessToken");
                        String accessTokenStr = null;
                        if (accessToken == null) {
                            JSONObject accessToken1 = WeixinGzhAppletsUtil.getGzhAccessToken();
                            logger.info("accessToken1===" + JSONObject.toJSONString(accessToken1));
                            accessToken1.put("expires_time", DateUtil.addSeconds(new Date(), accessToken1.getInteger("expires_in")));
                            redisService.set("accessToken", accessToken1);
                            accessTokenStr = accessToken1.getString("access_token");
                        } else {
                            JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(accessToken));
                            logger.info("accessToken===" + JSONObject.toJSONString(accessToken));
                            if (jsonObject.getDate("expires_time").before(new Date())) {
                                JSONObject accessToken2 = WeixinGzhAppletsUtil.getGzhAccessToken();
                                logger.info("accessToken2===" + JSONObject.toJSONString(accessToken2));
                                accessToken2.put("expires_time", DateUtil.addSeconds(new Date(), accessToken2.getInteger("expires_in")));
                                redisService.set("accessToken", accessToken2);
                                accessTokenStr = accessToken2.getString("access_token");
                            } else {
                                accessTokenStr = jsonObject.getString("access_token");
                            }
                        }
                        if (StringUtils.isNotEmpty(weiXinPushResult.getOpenId())) {
                            Map<String, String> content = new HashMap<>();
                            content.put("inquireOrderId", weiXinPushResult.getInquireOrderId() + "");
                            content.put("skuName", weiXinPushResult.getSkuName());
                            content.put("status", weiXinPushResult.getStatus());
                            content.put("createTime", DateUtil.getDateTime(weiXinPushResult.getCreateTime()));
                            WeixinGzhAppletsUtil.push("uhgZX_euKA6gvV66W7QroYGubIoJZnE4p3GWiK_2ZgQ"
                                    , accessTokenStr, weiXinPushResult.getOpenId(), content, "`pages/home/index?urlData=` + encodeURIComponent(JSON.stringify(`/pages/mine/subPages/fetures-detail/index?subOrderId=" + weiXinPushResult.getInquireOrderId() + "`))+");
                        }
                    } catch (BusinessException e) {
                        e.printStackTrace();
                        logger.error("#tongliSignContract# error" + e);
                    }
                }
            });
        } catch (BusinessException e) {
            return Result.failed(e.getCode(), e.getMessage());
        }
        result.setData("SUCCESS");
        return result;
    }


    @OperLog(operModul = "供应商-订单管理-设置运费", operDesc = "设置运费")
    @SupplierLoginCheck(alias = "SupplierOrderOperationAlias")
    @RequestMapping(value = "/order/cancel", method = {RequestMethod.POST})
    public Result<String> cancelOrder(HttpServletRequest request, @RequestBody JSONObject jsonObject) {
        LoginUser supplier = getSupplier();
        Result<String> result = Result.success(null);
        try {
            Integer inquireOrderId = jsonObject.getInteger("inquireOrderId");
            String cancelReason = jsonObject.getString("cancelReason");
            inquireOrderService.cancelOrder(inquireOrderId, supplier.getSupplierUserId(), RoleTypeEnum.SUPPLIER.getCode(), cancelReason);
        } catch (BusinessException e) {
            return Result.failed(e.getCode(), e.getMessage());
        }
        result.setData("SUCCESS");
        return result;
    }


    @OperLog(operModul = "供应商-订单管理-上传物流单好", operDesc = "设置运费")
    @SupplierLoginCheck(alias = "SupplierOrderOperationAlias")
    @RequestMapping(value = "/order/setDeliveryDemand", method = {RequestMethod.POST})
    public Result<String> setDeliveryDemand(HttpServletRequest request, @RequestBody InquireOrderDeliveryDemandReq req) {
        LoginUser supplier = getSupplier();
        Result<String> result = Result.success(null);
        try {
            req.setUserId(supplier.getSupplierUserId());
            req.setType(RoleTypeEnum.SUPPLIER.getCode());
            WeiXinPushResult weiXinPushResult = inquireOrderService.setDeliveryDemand(req);
            executorService.execute(new Runnable() {
                @Override
                public void run() {
                    try {
                        Object accessToken = redisService.get("accessToken");
                        String accessTokenStr = null;
                        if (accessToken == null) {
                            JSONObject accessToken1 = WeixinGzhAppletsUtil.getGzhAccessToken();
                            logger.info("accessToken1===" + JSONObject.toJSONString(accessToken1));
                            accessToken1.put("expires_time", DateUtil.addSeconds(new Date(), accessToken1.getInteger("expires_in")));
                            redisService.set("accessToken", accessToken1);
                            accessTokenStr = accessToken1.getString("access_token");
                        } else {
                            JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(accessToken));
                            logger.info("accessToken===" + JSONObject.toJSONString(accessToken));
                            if (jsonObject.getDate("expires_time").before(new Date())) {
                                JSONObject accessToken2 = WeixinGzhAppletsUtil.getGzhAccessToken();
                                logger.info("accessToken2===" + JSONObject.toJSONString(accessToken2));
                                accessToken2.put("expires_time", DateUtil.addSeconds(new Date(), accessToken2.getInteger("expires_in")));
                                redisService.set("accessToken", accessToken2);
                                accessTokenStr = accessToken2.getString("access_token");
                            } else {
                                accessTokenStr = jsonObject.getString("access_token");
                            }
                        }
                        if (StringUtils.isNotEmpty(weiXinPushResult.getOpenId())) {
                            Map<String, String> content = new HashMap<>();
                            content.put("inquireOrderId", weiXinPushResult.getInquireOrderId() + "");
                            content.put("skuName", weiXinPushResult.getSkuName());
                            content.put("status", weiXinPushResult.getStatus());
                            content.put("createTime", DateUtil.getDateTime(weiXinPushResult.getCreateTime()));
                            WeixinGzhAppletsUtil.push("uhgZX_euKA6gvV66W7QroYGubIoJZnE4p3GWiK_2ZgQ"
                                    , accessTokenStr, weiXinPushResult.getOpenId(), content, "`pages/home/index?urlData=` + encodeURIComponent(JSON.stringify(`/pages/mine/subPages/fetures-detail/index?subOrderId=" + weiXinPushResult.getInquireOrderId() + "`))+");
                        }
                    } catch (BusinessException e) {
                        e.printStackTrace();
                        logger.error("#tongliSignContract# error" + e);
                    }
                }
            });
        } catch (BusinessException e) {
            return Result.failed(e.getCode(), e.getMessage());
        }
        result.setData("SUCCESS");
        return result;
    }


    @OperLog(operModul = "供应商-订单管理-创建样品订单", operDesc = "设置运费")
    @SupplierLoginCheck(alias = "SupplierOrderOperationAlias")
    @RequestMapping(value = "/order/sampleOrder", method = {RequestMethod.POST})
    public Result<String> sampleOrder(HttpServletRequest request, @RequestBody SampleOrderReq req) {
        LoginUser supplier = getSupplier();
        Result<String> result = Result.success(null);
        try {
            req.setUserId(supplier.getSupplierUserId());
            req.setSupplierId(supplier.getSupplierId());
            req.setType(RoleTypeEnum.SUPPLIER.getCode());
            inquireOrderService.sampleOrder(req);
        } catch (BusinessException e) {
            return Result.failed(e.getCode(), e.getMessage());
        }
        result.setData("SUCCESS");
        return result;
    }

    @OperLog(operModul = "供应商-订单管理-检测订单列表", operDesc = "检测订单列表")
    @SupplierLoginCheck(alias = "SupplierTestOrderListAlias")
    @RequestMapping(value = "/test/order/list", method = {RequestMethod.POST})
    public Result<Page<InquireOrderTestingResult>> testOrderList(@RequestBody InquireOrderTestingReq req, HttpServletRequest request) {
        LoginUser supplier = getSupplier();
        PagerInfo pagerInfo = setDefaultPageInfo(req.getPageSize(), req.getPageIndex());
        Result<Page<InquireOrderTestingResult>> result = Result.success(null);
        req.setSupplierId(supplier.getSupplierId());
        Page<InquireOrderTestingResult> pagerByReq = inquireOrderTestingService.getPagerByReq(req, pagerInfo);
        result.setData(pagerByReq);
        return result;
    }

    @OperLog(operModul = "供应商-订单管理-检测订单详情", operDesc = "检测订单列表")
    @SupplierLoginCheck(alias = "SupplierTestOrderListAlias")
    @RequestMapping(value = "/test/order/detail", method = {RequestMethod.POST})
    public Result<InquireOrderTestingResult> testOrderDetail(@RequestBody JSONObject req, HttpServletRequest request) {
        LoginUser supplier = getSupplier();
        Result<InquireOrderTestingResult> result = Result.success(null);
        Integer id = req.getInteger("id");
        InquireOrderTestingResult detailById = inquireOrderTestingService.getDetailById(id, supplier.getSupplierId());
        result.setData(detailById);
        return result;
    }


    @OperLog(operModul = "供应商-订单管理-上传凭证", operDesc = "检测订单上传凭证")
    @SupplierLoginCheck(alias = "SupplierTestOrderOperationAlias")
    @RequestMapping(value = "/test/order/upload", method = {RequestMethod.POST})
    public Result<String> testOrderUploadReport(@RequestBody JSONObject req, HttpServletRequest request) {
        LoginUser supplier = getSupplier();
        Result<String> result = Result.success(null);
        Integer id = req.getInteger("id");
        String cover = req.getString("cover");
        try {
            inquireOrderTestingService.uploadReport(id, cover, supplier.getSupplierId());
        } catch (BusinessException e) {
            return Result.failed(e.getCode(), e.getMessage());
        }
        result.setData("success");
        return result;
    }


    @OperLog(operModul = "供应商-基础数据", operDesc = "基础数据")
    @RequestMapping(value = "/baseDeploy/list", method = {RequestMethod.POST})
    public Result<List<PlatformBaseDeployResult>> baseDeployList(HttpServletRequest request) {
        Result<List<PlatformBaseDeployResult>> result = Result.success(null);
        List<PlatformBaseDeployResult> list = platformBaseDeployService.getList();
        result.setData(list);
        return result;
    }

    @OperLog(operModul = "供应商-上传发票", operDesc = "上传发票")
    @RequestMapping(value = "/upload/invoice", method = {RequestMethod.POST})
    public Result<String> baseDeployList(@RequestBody JSONObject req,HttpServletRequest request) {
        Result<String> result = Result.success(null);
        Integer inquireOrderId = req.getInteger("inquireOrderId");
        String cover = req.getString("cover");
        InquireOrderContractResult inquireOrderContractResult=new InquireOrderContractResult();
        inquireOrderContractResult.setInquireOrderId(inquireOrderId);
        inquireOrderContractResult.setCover(cover);
        inquireOrderContractResult.setType(ContractTypeEnum.INVOICE.getCode());
        inquireOrderContractResult.setCreateTime(new Date());
        try {
            inquireOrderContractService.addOrUpdate(inquireOrderContractResult);
        } catch (BusinessException e) {
            return Result.failed(e.getCode(),e.getMessage());
        }
        return result;
    }
}
